package Behaviour;

import java.util.ArrayList;
import java.util.List;

import Model.Car;
import map.Map;
import jade.core.behaviours.OneShotBehaviour;

public class DeleteArrivedCars extends OneShotBehaviour{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Map map;
	public DeleteArrivedCars(Map map) {
		this.map = map;
	}
	
	@Override
	public void action() {
		List<Car> toDeleteCars = new ArrayList<Car>();
		List<Car> listCars = map.getCars();
		for (Car car : listCars) {
			if(car.checkFinish())
				toDeleteCars.add(car);
		}
		for (Car car : toDeleteCars) {
			map.getCars().remove(car);
		}
		
	}
	
	

}
